package cn.edu.scau.cmi.linyiqu.factory;

import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.linyiqu.simpleFactory.domain.Meat;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;

public class Controller implements Initializable {

	@FXML
	private TextArea output;
	@FXML
	private Button produceButton;
	@FXML
	private TextField meatInput;

	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		// TODO Auto-generated method stub
	}

	public void product(MouseEvent event){
		MeatFactory meatFactory=null;
		String input = meatInput.getText();
		switch(input) {
		case "beef": meatFactory=new BeefMeatFactory();
		break;
		case "pork": meatFactory=new PorkMeatFactory();
		break;
		case "chicken": meatFactory=new ChickenMeatFactory();
		break;
		default:output.appendText("sorry, there are no such factory to product "+input+"\n");
		}
		if(meatFactory!=null&&input!=null) {
			Meat meat = meatFactory.productMeat();
			output.appendText("Produced by the "+input+" factory: "+meat.toMeat());//toMeat 输出肉类的种类+对象
		}
	}
}